<template>
    <div class="check-order"
         v-loading="loading"
         element-loading-text="拼命加载中"
         element-loading-spinner="el-icon-loading"
         element-loading-background="rgba(255, 255, 255, 0.6)">
        <dialog-see-order-distribution-map  :order-distribution="checkedInfo" :area-data="areaData" ></dialog-see-order-distribution-map>
    </div>
</template>

<script>
    import DialogSeeOrderDistributionMap from '../../components/dialogModel/SeeOrderDistributionMap.vue';
    export default {
        name: 'spot-detail',
        props: {
            params: {
                type: Object,
                default: () => {
                    return {}
                }
            }
        },
        components: {
            DialogSeeOrderDistributionMap
        },
        data() {
            return {
                checkedInfo: [],
                loading:false,
                areaData: [],
                areaApi: 'express/area?status=1&pageSize=400',
            }
        },
        computed: {
            id: function (value) {
                return this.params.id
            }
        },
        created() {
            if (localStorage.getItem('areaList')) {// 区域暂时关闭
                this.areaData = JSON.parse(localStorage.getItem('areaList'));
            } else {
                this.getArea();
            }
            this.getSpotInfo();
        },
        methods: {
            getSpotInfo() {
                this.loading = true;
                let api = 'express/order?size=1&pageSize=' + this.id.length + '&id$=[' + this.id + ']';
                this.$http.get(api)
                    .then((res) => {
                        this.checkedInfo = res.data.data;
                        this.loading = false;
                    })
                    .catch((error) => {
                        this.loading = false;
                        if (error.response.data.msg) {
                            this.$message.error(error.response.data.msg);
                        } else {
                            this.$message.error('请求错误：' + error.response.status);
                        }
                    });
            },
            getArea() {
                this.$http.get(this.areaApi)
                    .then((response) => {
                        this.areaData = response.data.data;
                    })
                    .catch((error) => {
                        this.$message.error('请求数据错误');
                    });
            } // 获取区域信息
        }
    }
</script>

<style scoped lang="less">
.check-order{
    padding: 6px;
}
</style>
